//
//  StoryBottomView.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/31.
//

#import "StoryBottomView.h"
#import "CommonUtil.h"



@interface StoryBottomView()
@property (strong, nonatomic) UIImageView *iconImageView;
@property (strong, nonatomic) UIButton *zanBtn;
@property (strong, nonatomic) UIButton *commontBtn;
@property (strong, nonatomic) UIButton *shareBtn;
@property (strong, nonatomic) UIButton *dashangBtn;
@end

@implementation StoryBottomView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.iconImageView];
        [self addSubview:self.inputBtn];
        [self addSubview:self.zanBtn];
        [self addSubview:self.commontBtn];
        [self addSubview:self.shareBtn];
        [self addSubview:self.dashangBtn];
    }
    return self;
}

- (void)btnClick:(UIButton *)sender{
    if ([sender.titleLabel.text isEqualToString:@"点赞"]) {
        sender.selected = !sender.selected;
    }
}


#pragma mark - lazy
-(UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(AD(20),AD(10), AD(30), AD(30))];
        _iconImageView.image = [UIImage imageNamed:@"defaultIcon.jpeg"];
        _iconImageView.layer.cornerRadius = AD(15);
        _iconImageView.clipsToBounds = YES;
    }
    return _iconImageView;
}

-(UIButton *)inputBtn{
    if (!_inputBtn) {
        _inputBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_inputBtn setTitle:@"说点什么...           " forState:UIControlStateNormal];
        [_inputBtn setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.1] forState:UIControlStateNormal];
        _inputBtn.titleLabel.font = [UIFont systemFontOfSize:AD(13)];
        _inputBtn.layer.cornerRadius = AD(15);
        _inputBtn.layer.borderColor = [[UIColor blackColor] colorWithAlphaComponent:0.1].CGColor;
        _inputBtn.layer.borderWidth = AD(1);
        _inputBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
        _inputBtn.frame = CGRectMake(self.iconImageView.right + AD(5), AD(7.5), AD(120), AD(30));
    }
    return _inputBtn;
}

-(UIButton *)zanBtn{
    if (!_zanBtn) {
        _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_zanBtn setTitle:@"点赞" forState:UIControlStateNormal];
        [_zanBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [_zanBtn setTitleColor:RGB(255.0, 90.0, 117.0) forState:UIControlStateSelected];
        _zanBtn.titleLabel.font = [UIFont systemFontOfSize:AD(12)];
        [_zanBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_zanBtn setImage:[UIImage imageNamed:@"icon_zan_normal"] forState:UIControlStateNormal];
        [_zanBtn setImage:[UIImage imageNamed:@"icon_zan_select"] forState:UIControlStateSelected];
        _zanBtn.frame = CGRectMake(_inputBtn.right + AD(10), 0, AD(35), self.height);
        _zanBtn.titleEdgeInsets = UIEdgeInsetsMake(AD(0), -AD(10), 0, 0);
        _zanBtn.imageEdgeInsets = UIEdgeInsetsMake(-AD(30), AD(12), 0, 0);
    }
    return _zanBtn;
}
-(UIButton *)commontBtn{
    if (!_commontBtn) {
        _commontBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_commontBtn setTitle:@"评论" forState:UIControlStateNormal];
        [_commontBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _commontBtn.titleLabel.font = [UIFont systemFontOfSize:AD(12)];
        [_commontBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_commontBtn setImage:[UIImage imageNamed:@"icon_feed"] forState:UIControlStateNormal];
        _commontBtn.frame = CGRectMake(_zanBtn.right + AD(15), 0, AD(35), self.height);
        _commontBtn.titleEdgeInsets = UIEdgeInsetsMake(AD(0), -AD(10), 0, 0);
        _commontBtn.imageEdgeInsets = UIEdgeInsetsMake(-AD(30), AD(12), 0, 0);
    }
    return _commontBtn;
}

-(UIButton *)shareBtn{
    if (!_shareBtn) {
        _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_shareBtn setTitle:@"分享" forState:UIControlStateNormal];
        [_shareBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _shareBtn.titleLabel.font = [UIFont systemFontOfSize:AD(12)];
        [_shareBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_shareBtn setImage:[UIImage imageNamed:@"icon_feed"] forState:UIControlStateNormal];
        _shareBtn.frame = CGRectMake(_commontBtn.right + AD(15), 0, AD(35), self.height);
        _shareBtn.titleEdgeInsets = UIEdgeInsetsMake(AD(0), -AD(10), 0, 0);
        _shareBtn.imageEdgeInsets = UIEdgeInsetsMake(-AD(30), AD(12), 0, 0);
    }
    return _shareBtn;
}


-(UIButton *)dashangBtn{
    if (!_dashangBtn) {
        _dashangBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_dashangBtn setTitle:@"打赏" forState:UIControlStateNormal];
        [_dashangBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _dashangBtn.titleLabel.font = [UIFont systemFontOfSize:AD(12)];
        [_dashangBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_dashangBtn setImage:[UIImage imageNamed:@"icon_dashang"] forState:UIControlStateNormal];
        _dashangBtn.frame = CGRectMake(_shareBtn.right + AD(15), 0, AD(35), self.height);
        _dashangBtn.titleEdgeInsets = UIEdgeInsetsMake(AD(0), -AD(10), 0, 0);
        _dashangBtn.imageEdgeInsets = UIEdgeInsetsMake(-AD(30), AD(12), 0, 0);
    }
    return _dashangBtn;
}


@end
